package com.yu.Demo04;

public class Synch {

    public synchronized void A(){
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized void B(){}

    public static void main(String[] args) {
        synchronized (Synch.class){}
        Synch synch = new Synch();

            new Thread(()-> {
                synch.A();
                System.out.println("线程A访问到了");
            },"线程A").start();

        new Thread(()-> {
            synch.A();
            System.out.println("线程C访问到了");
        },"线程A").start();

        new Thread(()-> {
            synch.B();
            System.out.println("线程B访问到了");
        },"线程B").start();


    }

}
